export const columns = [
  { label: '', prop: 'index', width: '80px', type: 'index' },
  { label: '小区名称', prop: 'name', width: '120px', search: true },
  { label: '省', prop: 'province', width: '100px' },
  { label: '市', prop: 'city', width: '100px' },
  { label: '区县', prop: 'district', width: '100px' },
  { label: '详细地址', prop: 'address', width: '180px' },
  { label: '小区图片', prop: 'imageUrl', type: 'image', width: '150px' },
  {
    label: '创建时间',
    prop: 'createTime',
    width: '180px',
    type: 'datetime',
  },
  { label: '状态', prop: 'status', width: '100px', type: 'select', options: $enums.status, search: true },
  {
    label: '是否默认',
    prop: 'isDefault',
    type: 'radio',
    options: [
      { label: '是', value: 0 },
      { label: '否', value: 1 },
    ],
    width: '100px',
  },
  { label: '操作', prop: 'action', slotName: 'action', width: '260px', fixed: 'right' },
]

export const formOptions = [
  { label: '小区名称', prop: 'name', rules: [{ required: true, message: '小区名称不能为空' }] },
  {
    label: '是否默认',
    prop: 'isDefault',
    type: 'radio',
    options: [
      { label: '是', value: 0 },
      { label: '否', value: 1 },
    ],
  },
  {
    label: '所属地区',
    prop: 'provinceCode',
    type: 'cascader',
    attrs: {
      props: { label: 'name', value: 'id' },
    },
    options: async () => {
      try {
        const res = await $request.get('/api-parking/region/tree')
        return res || []
      } catch (error) {
        return []
      }
    },
    rules: [{ required: true, type: 'array', message: '所属地区不能为空', trigger: 'change' }],
  },

  { label: '详细地址', prop: 'address', span: 3 },
  { label: '小区图片', prop: 'imageUrl', span: 3, type: 'image' },
]
